import 'dart:math';

import 'package:charts_flutter/flutter.dart' as charts;

import 'package:flutter/material.dart';

class LinearSales {
  final String title;
  final double sales;
  final charts.Color colors;

  LinearSales(this.title, this.sales, this.colors);
}

class PieOutsideLabelChart extends StatelessWidget {
  final List<charts.Series> seriesList;
  final bool animate;
  final double arcRatio;
  final bool outSideLabel;

  PieOutsideLabelChart(
    this.seriesList, {
    this.animate,
    this.arcRatio = 1,
    this.outSideLabel = false,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      child: charts.PieChart(
        seriesList,
        animate: animate,
        layoutConfig: charts.LayoutConfig(
          leftMarginSpec: charts.MarginSpec.fixedPixel(0),
          rightMarginSpec: charts.MarginSpec.fixedPixel(0),
          topMarginSpec: charts.MarginSpec.fixedPixel(30),
          bottomMarginSpec: charts.MarginSpec.fixedPixel(30),
        ),
        defaultRenderer: charts.ArcRendererConfig(
          arcRendererDecorators: outSideLabel
              ? [
                  charts.ArcLabelDecorator(
                      labelPosition: charts.ArcLabelPosition.outside,
                      leaderLineStyleSpec: charts.ArcLabelLeaderLineStyleSpec(
                          length: 20.0,
                          thickness: 1.0,
                          color: charts.Color(r: 100, g: 100, b: 100))),
                ]
              : [],
          arcRatio: arcRatio,
        ),
      ),
    );
  }
}
